package com.sairobo.live.auth.impl;

import com.sairobo.live.auth.TokenAuth;
import com.sairobo.live.util.AccessStateHelper;
import com.sairobo.live.util.SpringUtil;
import com.sairobo.live.token.TokenServiceFeign;
import com.sairobo.live.util.TokenUtils;
import com.netflix.zuul.context.RequestContext;
import io.jsonwebtoken.Claims;

/**
 * app端token校验实现
 */
public class AppTokenAuth extends TokenAuth {

    public AppTokenAuth(String prefix, String[] urlPatterns, TokenServiceFeign tokenServiceFeign) {
        super(prefix, urlPatterns, tokenServiceFeign);
    }

    @Override
    protected void tokenAvailable(RequestContext requestContext,String token,Claims claims) {
        TokenUtils tokenUtils = SpringUtil.getBean(TokenUtils.class);
        //app当前规则,token存在且未失效则通过校验可以访问接口
        AccessStateHelper.accessSuccess(requestContext, claims.getSubject());
    }
}
